#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=2e5;
#define INF 0x7fffffff
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//
int n;
void solve()
{	
	sd(n);
	if(n&1)
	{
		if(n==3) puts("NO");
		else
		{
			puts("YES");
			int t1=(n-1)/2;
			int t2=-(t1-1);
			for(int i=1;i<=n;i++)
			{
				if(i&1) cout<<t2<<" ";
				else cout<<t1<<" ";
			}
			puts("");
		}

	}
	else if(!(n&1))
	{
		puts("YES");
		for(int i=1;i<=n;i++)
		{
			if(i&1) cout<<1<<" ";
			else cout<<-1<<" ";
		}
		puts("");
		return;
	}
}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}		